Skip to content

added bogobogosort #1258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2019
Merged

added bogobogosort #1258

merged 2 commits into from
Oct 3, 2019

Conversation

WilliamHYZhang
Copy link
Contributor

Hi,

Added code for bogobogosort in seperate PR. Thanks for the previous feedback.

Hope this helps!

:return: the list sorted in ascending order

Examples:
>>> bogo_bogo_sort([0, 5, 3, 2, 2])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least one test should have at least one:

  • negative integer
  • negative float
  • zero
  • positive integer
  • positive float

What happens when we bogo_bogo_sort(list("Hello!")) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test #2 has negative integer, does that satisfy the requirement?
For bogo_bogo_sort(list("Hello!")) error would be caught has line 53 converts input to integer and would raise ValueError, would you like me to add a try/catch in the algorithm function as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mixing pos int, pos float, zero, neg int, neg float in a single test was what I was looking for.

Traceback (most recent call last):
Tests for a ValueError.

@WilliamHYZhang WilliamHYZhang requested a review from cclauss October 3, 2019 00:02
@cclauss cclauss merged commit 0e333ae into TheAlgorithms:master Oct 3, 2019
stokhos pushed a commit to stokhos/Python that referenced this pull request Jan 3, 2021
* added bogobogosort

* fix indentation error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants